package com.jdrx.sw.sewage.api.web;

import com.jdrx.platform.commons.rest.beans.vo.ResponseVO;
import com.jdrx.platform.commons.rest.exception.BizException;
import com.jdrx.platform.commons.rest.factory.ResponseFactory2;
import com.jdrx.sw.sewage.beans.dto.AlarmSetDTO;
import com.jdrx.sw.sewage.beans.vo.AlarmSetVO;
import com.jdrx.sw.sewage.common.constant.Constant;
import com.jdrx.sw.sewage.service.AlarmSetServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/api/alarmset")
@Api(value = "告警设置")
public class AlarmSetApi {

    @Autowired
    private AlarmSetServiceImpl alarmSetServiceImpl;

    @ApiOperation(value = "告警设置列表")
    @RequestMapping(value = "selectList", method = RequestMethod.POST)
    public ResponseVO<List<AlarmSetVO>> selectList(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                                   @RequestHeader(Constant.TENANT_ID) String tenantId) {
        return ResponseFactory2.ok(alarmSetServiceImpl.selectList());
    }

    @ApiOperation(value = "告警设置修改(仅黄色告警能修改)")
    @RequestMapping(value = "updateYellowAlarmSetById", method = RequestMethod.POST)
    public ResponseVO updateYellowAlarmSetById(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                               @RequestHeader(Constant.TENANT_ID) String tenantId,
                                               @RequestBody AlarmSetDTO alarmSetDTO) throws BizException {
        return alarmSetServiceImpl.updateYellowAlarmSetById(alarmSetDTO);
    }

    @ApiOperation(value = "告警设置生效")
    @RequestMapping(value = "updateRedAlarmSetById", method = RequestMethod.GET)
    public ResponseVO updateRedAlarmSetById(@RequestHeader(Constant.DATA_NODE) String dataNode,
                                            @RequestHeader(Constant.TENANT_ID) String tenantId,
                                            @RequestParam Long alarmSetId) throws BizException {
        return alarmSetServiceImpl.updateRedAlarmSetById(alarmSetId);
    }
}
